package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

/**
 * @Author 梁科
 * @Version 1.0
 * @ Date 2025/10/28 16:04
 */
@Mapper
public interface AddressBookMapper {
    /**
     * 增加地址簿
     * @param addressBook
     */
    void insert(AddressBook addressBook);

    /**
     * 查询当前用户的所有地址簿
     * @param userId
     * @return
     */
    List<AddressBook> getAllByUserId(Long userId);

    /**
     * 根据id查询地址簿
     * @param id
     * @return
     */
    @Select(value = "select * from address_book where id = #{id}")
    AddressBook getById(Long id);

    /**
     * 修改地址簿
     * @param addressBook
     */
    void update(AddressBook addressBook);

    /**
     * 查询某个用户的默认地址
     * @param addressBook1
     * @return
     */
    AddressBook getDefaultAddress(AddressBook addressBook1);

    /**
     * 根据id删除地址
     * @param id
     */
    @Delete(value = "delete from address_book where id = #{id}")
    void deleteById(Long id);
}
